<?php

class Histories extends DatabaseTable{
      public function __construct($conn) {
        parent::__construct($conn);
    }

    protected function load(){
        $histories_table="history";
        $query=sprintf("SELECT count(*) AS counter FROM %s",
            mysql_real_escape_string($histories_table));
	$result=mysql_query($query,$this->conn);
	if ($result){
            while ($row = mysql_fetch_assoc($result)) {
                $value=$row['counter'];
                $this->records['counter'] = $value;
            }
        }
	mysql_free_result($result);
    }

    public function store(History $hist){
        $histories_table="history";
        $query=sprintf("INSERT INTO %s (ip,user_agent,locale) VALUES ('%s','%s','%s')",
            mysql_real_escape_string($histories_table),
            mysql_real_escape_string($hist->getIp()),
            mysql_real_escape_string($hist->getUserAgent()),
            mysql_real_escape_string($hist->getLocale())
        );
	$result=mysql_query($query,$this->conn);
    }

}
?>
